package com.lambda.hybrid.handler;

import android.content.SharedPreferences;

import com.lambda.hybrid.Callback;

import org.json.JSONObject;

public class SetStorageHandler extends AbstractHandler {
    private final SharedPreferences mSharedPre;

    public SetStorageHandler(SharedPreferences storage) {
        mSharedPre = storage;
    }

    @Override
    public void onHandle(String data, Callback callback) throws Exception {
        JSONObject table = new JSONObject(data);
        mSharedPre.edit().putString(
                table.getString("key"),
                table.getString("value")
        ).apply();
    }
}
